/**
 * @constructor
 */
function WebGL(canvas) {
    try {
        /** webGL context */
        this.gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
    } catch (e) {
        console.log("Could not initialize webGL.");
        return;
    }

    /**
     * Gets a shader of a given type from the URL of its source,
     * compiles it and runs a callback on success.
     */
    this.getShader = function(shaderUrl, shaderType, successCallback) {
        var tmpThis = this;
        $.get(
        shaderUrl,
        function (shaderSource) {
            shader = this.gl.createShader(shaderType);

            this.gl.shaderSource(shader, shaderSource);

            this.gl.compileShader(shader);
            
            if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
                console.log("An error occurred compiling the shaders: " + gl.getShaderInfoLog(shader));
            } else {
                successCallback(shader);
            }
        },
        "text");
    }
}